import request from "@/utils/request.ts";
import type {AllRoleRes, ResUserType, SetRole, UserData} from "@/api/acl/user/type.ts";


export const reqUser = (page: number, size: number,keyword:string) => request.get<any, ResUserType>(`/admin/acl/user/${page}/${size}?username=${keyword}`)
export const reqSaveOrUpdateUser = (data: UserData) => {
    if (data.id) {
        return request.put("/admin/acl/user/update", data);
    } else {
        return request.post("/admin/acl/user/save", data);
    }
}

export const reqGetAllRoles = (id: number) => request.get<any, AllRoleRes>(`/admin/acl/user/toAssign/${id}`)

export const reqSetRole = (data: SetRole) => request.post('/admin/acl/user/doAssignRole', data);

export const reqDeleteOne = (id: number) => request.delete(`/admin/acl/user/remove/${id}`)
export const reqDeleteUsers = (ids: number[]) => request.delete('/admin/acl/user/batchRemove', {data: ids})